using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VBABST
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {
            #region
            #endregion
            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT": 
                    #region
                    dwReturn["BMMANDANT"] = "00";
                    dwReturn["BMBAUMKRS"] = "SZ";
                    dwReturn["BMBAUMLFD"] = "000000";
                    dwReturn["BMKART"] = "                    ";
                    dwReturn["BMKVAR"] = "  ";
                    dwReturn["BMFARBE"] = "          ";
                    dwReturn["BMZENSUR"] = " ";
                    dwReturn["BMZUSTAND"] = "    ";
                    dwReturn["BMSCHLICHTGR"] = "     ";
                    dwReturn["BMSCHLICHTNR"] = "000000000000000";
                    dwReturn["BMBAUMKZ"] = "Z";
                    dwReturn["BMVERWEN"] = "S";
                    dwReturn["BMHERART"] = "S";
                    dwReturn["BMFDZ"] = "3844";
                    dwReturn["BMGABED"] = "J";
                    dwReturn["BMKETTTYP"] = "01    ";
                    dwReturn["BMKANTE"] = "  ";
                    dwReturn["BMLO"] = "01";
                    dwReturn["BMLB"] = "ZZ";
                    dwReturn["BMLP"] = "        ";
                    dwReturn["BMAUFBKZ"] = " ";
                    dwReturn["BMDATERL"] = "0";
                    dwReturn["BMBEM"] = "                                        ";
                    dwReturn["BMKOLLINR"] = "A       ";
                    dwReturn["BMSPSTA"] = "  ";
                    dwReturn["BMSPGRD"] = "  ";
                    dwReturn["BMORGKZ"] = "J";
                    dwReturn["BMLEER"] = " ";
                    dwReturn["BMSOLLKZ"] = " ";
                    dwReturn["BMSOLLLG"] = "0";
                    dwReturn["BMSOLLGEW"] = "0";
                    dwReturn["BMSOLLVLG"] = "0";
                    dwReturn["BMSOLLSTK"] = "0";
                    dwReturn["BMISTLG"] = "0";
                    dwReturn["BMISTGEW"] = "0";
                    dwReturn["BMISTVLG"] = "0";
                    dwReturn["BMISTSTK"] = "0";
                    dwReturn["BMRESTLG"] = "0";
                    dwReturn["BMURISTLG"] = "0";
                    dwReturn["BMRESTGEW"] = "0";
                    dwReturn["BMKGNET"] = "0";
                    dwReturn["BMKGBRUT"] = "0";
                    dwReturn["BMTARAI"] = "0";
                    dwReturn["BMTARAA"] = "0";
                    dwReturn["BMAUFKRS"] = "  ";
                    dwReturn["BMAUFLFD"] = "000000";
                    dwReturn["BMAUFPOS"] = "001";
                    dwReturn["BMSA"] = "320";
                    dwReturn["BMAUFTYP"] = "V";
                    dwReturn["BMFERTKZ"] = "E";
                    dwReturn["BMPRODLO"] = "01";
                    dwReturn["BMPRODLB"] = "QZ";
                    dwReturn["BMPRODLP"] = "        ";
                    dwReturn["BMPRODAUFBKZ"] = " ";
                    dwReturn["BMSPPART"] = "          ";
                    dwReturn["BMPARTIE"] = "0000000";
                    dwReturn["BMPARTIEKZ"] = "0";
                    dwReturn["BMDATVW"] = "0";
                    dwReturn["BMDATDRU"] = "0";
                    dwReturn["BMDATABG"] = "0";
                    dwReturn["BMDATRP"] = "0";
                    dwReturn["BMDATRPM"] = "0";
                    dwReturn["BMDATANG"] = "0";
                    dwReturn["BMDATABWEB"] = "0";
                    dwReturn["BMERSATZKZ"] = " ";
                    dwReturn["BMKOMBIKZ"] = " ";
                    dwReturn["BMANZTB"] = "0";
                    dwReturn["BMBAHNIG"] = "0";
                    dwReturn["BMPICKUP"] = "0";
                    dwReturn["BMABAUMKRS"] = "  ";
                    dwReturn["BMABAUMLFD"] = "000000";
                    dwReturn["BMSTKZL"] = "0";
                    dwReturn["BMBAABGZ"] = " ";
                    dwReturn["BMAPOS"] = "0001";
                    dwReturn["BMRAFOLGE"] = "010";
                    dwReturn["BMAUSFFRB"] = "0";
                    dwReturn["BMTAX"] = "   ";
                    dwReturn["BMSCHIENE"] = "     ";
                    dwReturn["BMMNRKRS"] = "  ";
                    dwReturn["BMMLFDNR"] = "    ";
                    dwReturn["BMMPOS"] = "00";
                    dwReturn["BMMAPOS"] = "00";
                    dwReturn["BMDL"] = " ";
                    dwReturn["BMBEARB"] = "        ";
                    dwReturn["BMZULO"] = "  ";
                    dwReturn["BMZULB"] = "  ";
                    dwReturn["BMZULP"] = "        ";
                    dwReturn["BMZUAUFBKZ"] = " ";
                    dwReturn["BMRART"] = "                    ";
                    dwReturn["BMRVAR"] = "  ";
                    dwReturn["BMRFARBE"] = "          ";
                    dwReturn["BMLIEFNR"] = "        ";
                    dwReturn["BMBESTKZ"] = " ";
                    dwReturn["BMBNRLIEF"] = "          ";
                    dwReturn["BMEGKZ"] = " ";
                    dwReturn["BMLIEFSCHNR"] = "        ";
                    dwReturn["BMLIEFDAT"] = "0";
                    dwReturn["BMRECHNR"] = "          ";
                    dwReturn["BMKLABR"] = " ";
                    dwReturn["BMEINPR"] = "0";
                    dwReturn["BMRECHDAT"] = "0";
                    dwReturn["BMBDEKZ"] = "1";
                    dwReturn["BMJJJJBDE"] = "0";
                    dwReturn["BMBNRBDE"] = "0";
                    dwReturn["BMDATBDE"] = "0000000000";
                    dwReturn["BMBDEBKZ"] = " ";
                    dwReturn["BMJJJJMAT"] = "0";
                    dwReturn["BMBNRMAT"] = "0";
                    dwReturn["BMDATMAT"] = "0";
                    dwReturn["BMISOLLLG"] = "0";
                    dwReturn["BMIISTLG"] = "0";
                    dwReturn["BMIDIFFLG"] = "0";
                    dwReturn["BMIDATUM"] = "0";
                    dwReturn["BMISTATUS"] = " ";
                    dwReturn["BMIJJJJ"] = "0";
                    dwReturn["BMIBELEGNR"] = "0";
                    dwReturn["BMIBPOSVON"] = "0";
                    dwReturn["BMIBPOSBIS"] = "0";
                    dwReturn["BMRODA"] = "1";
                    dwReturn["BMWIND"] = "0";
                    dwReturn["BMVWMNRKRS"] = "  ";
                    dwReturn["BMVWMLFDNR"] = "0000";
                    dwReturn["BMVWMPOS"] = "00";
                    dwReturn["BMMUKZ"] = " ";
                    dwReturn["BMZTERL"] = "0000";
                    dwReturn["BMVERSION"] = "0";
                    dwReturn["BMKGBRUTGW"] = "0";
                    dwReturn["BMFILLER"] = "                                                            ";
                    dwReturn["BMAENDZL"] = "1";
                    dwReturn["BMAENDBEN"] = "        ";
                    dwReturn["BMAENDDAT"] = "0";
                    dwReturn["BMNEUBEN"] = "        ";
                    dwReturn["BMNEUDAT"] = "0";

                    #endregion
                    break;
                case "JLT":
                default:
                    #region
                    dwReturn["BMMANDANT"] = "00";
                    dwReturn["BMBAUMKRS"] = "SZ";
                    dwReturn["BMBAUMLFD"] = "001911";
                    dwReturn["BMKART"] = "J5-0002             ";
                    dwReturn["BMKVAR"] = "1 ";
                    dwReturn["BMFARBE"] = "1         ";
                    dwReturn["BMZENSUR"] = "1";
                    dwReturn["BMZUSTAND"] = "    ";
                    dwReturn["BMSCHLICHTGR"] = "     ";
                    dwReturn["BMSCHLICHTNR"] = "000000000000000";
                    dwReturn["BMBAUMKZ"] = "Z";
                    dwReturn["BMVERWEN"] = "S";
                    dwReturn["BMHERART"] = "S";
                    dwReturn["BMFDZ"] = "3844";
                    dwReturn["BMGABED"] = "J";
                    dwReturn["BMKETTTYP"] = "01    ";
                    dwReturn["BMKANTE"] = "  ";
                    dwReturn["BMLO"] = "01";
                    dwReturn["BMLB"] = "ZZ";
                    dwReturn["BMLP"] = "M 020200";
                    dwReturn["BMAUFBKZ"] = " ";
                    dwReturn["BMDATERL"] = "20150121";
                    dwReturn["BMBEM"] = "                                        ";
                    dwReturn["BMKOLLINR"] = "A       ";
                    dwReturn["BMSPSTA"] = "  ";
                    dwReturn["BMSPGRD"] = "  ";
                    dwReturn["BMORGKZ"] = "J";
                    dwReturn["BMLEER"] = " ";
                    dwReturn["BMSOLLKZ"] = " ";
                    dwReturn["BMSOLLLG"] = "26290";
                    dwReturn["BMSOLLGEW"] = "518707";
                    dwReturn["BMSOLLVLG"] = "26500";
                    dwReturn["BMSOLLSTK"] = "0";
                    dwReturn["BMISTLG"] = "26500";
                    dwReturn["BMISTGEW"] = "505000";
                    dwReturn["BMISTVLG"] = "0";
                    dwReturn["BMISTSTK"] = "0";
                    dwReturn["BMRESTLG"] = "26500";
                    dwReturn["BMURISTLG"] = "25600";
                    dwReturn["BMRESTGEW"] = "522850";
                    dwReturn["BMKGNET"] = "0";
                    dwReturn["BMKGBRUT"] = "0";
                    dwReturn["BMTARAI"] = "0";
                    dwReturn["BMTARAA"] = "0";
                    dwReturn["BMAUFKRS"] = "JS";
                    dwReturn["BMAUFLFD"] = "000550";
                    dwReturn["BMAUFPOS"] = "001";
                    dwReturn["BMSA"] = "320";
                    dwReturn["BMAUFTYP"] = "V";
                    dwReturn["BMFERTKZ"] = "E";
                    dwReturn["BMPRODLO"] = "01";
                    dwReturn["BMPRODLB"] = "QZ";
                    dwReturn["BMPRODLP"] = "01      ";
                    dwReturn["BMPRODAUFBKZ"] = " ";
                    dwReturn["BMSPPART"] = "          ";
                    dwReturn["BMPARTIE"] = "0005397";
                    dwReturn["BMPARTIEKZ"] = "0";
                    dwReturn["BMDATVW"] = "0";
                    dwReturn["BMDATDRU"] = "0";
                    dwReturn["BMDATABG"] = "0";
                    dwReturn["BMDATRP"] = "0";
                    dwReturn["BMDATRPM"] = "0";
                    dwReturn["BMDATANG"] = "20151025";
                    dwReturn["BMDATABWEB"] = "0";
                    dwReturn["BMERSATZKZ"] = " ";
                    dwReturn["BMKOMBIKZ"] = " ";
                    dwReturn["BMANZTB"] = "0";
                    dwReturn["BMBAHNIG"] = "0";
                    dwReturn["BMPICKUP"] = "0";
                    dwReturn["BMABAUMKRS"] = "  ";
                    dwReturn["BMABAUMLFD"] = "000000";
                    dwReturn["BMSTKZL"] = "0";
                    dwReturn["BMBAABGZ"] = " ";
                    dwReturn["BMAPOS"] = "0001";
                    dwReturn["BMRAFOLGE"] = "010";
                    dwReturn["BMAUSFFRB"] = "0";
                    dwReturn["BMTAX"] = "   ";
                    dwReturn["BMSCHIENE"] = "     ";
                    dwReturn["BMMNRKRS"] = "M ";
                    dwReturn["BMMLFDNR"] = "0202";
                    dwReturn["BMMPOS"] = "00";
                    dwReturn["BMMAPOS"] = "00";
                    dwReturn["BMDL"] = " ";
                    dwReturn["BMBEARB"] = "        ";
                    dwReturn["BMZULO"] = "  ";
                    dwReturn["BMZULB"] = "  ";
                    dwReturn["BMZULP"] = "        ";
                    dwReturn["BMZUAUFBKZ"] = " ";
                    dwReturn["BMRART"] = "                    ";
                    dwReturn["BMRVAR"] = "  ";
                    dwReturn["BMRFARBE"] = "          ";
                    dwReturn["BMLIEFNR"] = "        ";
                    dwReturn["BMBESTKZ"] = " ";
                    dwReturn["BMBNRLIEF"] = "          ";
                    dwReturn["BMEGKZ"] = " ";
                    dwReturn["BMLIEFSCHNR"] = "        ";
                    dwReturn["BMLIEFDAT"] = "0";
                    dwReturn["BMRECHNR"] = "          ";
                    dwReturn["BMKLABR"] = " ";
                    dwReturn["BMEINPR"] = "0";
                    dwReturn["BMRECHDAT"] = "0";
                    dwReturn["BMBDEKZ"] = "1";
                    dwReturn["BMJJJJBDE"] = "0";
                    dwReturn["BMBNRBDE"] = "0";
                    dwReturn["BMDATBDE"] = "0000000000";
                    dwReturn["BMBDEBKZ"] = " ";
                    dwReturn["BMJJJJMAT"] = "2015";
                    dwReturn["BMBNRMAT"] = "258644";
                    dwReturn["BMDATMAT"] = "0";
                    dwReturn["BMISOLLLG"] = "0";
                    dwReturn["BMIISTLG"] = "0";
                    dwReturn["BMIDIFFLG"] = "0";
                    dwReturn["BMIDATUM"] = "0";
                    dwReturn["BMISTATUS"] = " ";
                    dwReturn["BMIJJJJ"] = "0";
                    dwReturn["BMIBELEGNR"] = "0";
                    dwReturn["BMIBPOSVON"] = "0";
                    dwReturn["BMIBPOSBIS"] = "0";
                    dwReturn["BMRODA"] = "1";
                    dwReturn["BMWIND"] = "0";
                    dwReturn["BMVWMNRKRS"] = "  ";
                    dwReturn["BMVWMLFDNR"] = "0320";
                    dwReturn["BMVWMPOS"] = "00";
                    dwReturn["BMMUKZ"] = " ";
                    dwReturn["BMZTERL"] = "0849";
                    dwReturn["BMVERSION"] = "0";
                    dwReturn["BMKGBRUTGW"] = "0";
                    dwReturn["BMFILLER"] = "                                                            ";
                    dwReturn["BMAENDZL"] = "13";
                    dwReturn["BMAENDBEN"] = "INTEXE  ";
                    dwReturn["BMAENDDAT"] = "20151025";
                    dwReturn["BMNEUBEN"] = "SYD     ";
                    dwReturn["BMNEUDAT"] = "20150121";

                    #endregion
                    break;
            }
        }

        public void InsertBABST(DataRow dwData)
        {
      
            dwData["BMNEUBEN"] = app.User;
            dwData["BMNEUDAT"] = date;
            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {
                default:
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                    or1.CommandText = "INSERT INTO BABST ( BMMANDANT,BMBAUMKRS,BMBAUMLFD,BMKART,BMKVAR,BMFARBE,BMZENSUR,BMZUSTAND,BMSCHLICHTGR,BMSCHLICHTNR,BMBAUMKZ,BMVERWEN,BMHERART,BMFDZ,BMGABED,BMKETTTYP,BMKANTE,BMLO,BMLB,BMLP,BMAUFBKZ,BMDATERL,BMBEM,BMKOLLINR,BMSPSTA,BMSPGRD,BMORGKZ,BMLEER,BMSOLLKZ,BMSOLLLG,BMSOLLGEW,BMSOLLVLG,BMSOLLSTK,BMISTLG,BMISTGEW,BMISTVLG,BMISTSTK,BMRESTLG,BMURISTLG,BMRESTGEW,BMKGNET,BMKGBRUT,BMTARAI,BMTARAA,BMAUFKRS,BMAUFLFD,BMAUFPOS,BMSA,BMAUFTYP,BMFERTKZ,BMPRODLO,BMPRODLB,BMPRODLP,BMPRODAUFBKZ,BMSPPART,BMPARTIE,BMPARTIEKZ,BMDATVW,BMDATDRU,BMDATABG,BMDATRP,BMDATRPM,BMDATANG,BMDATABWEB,BMERSATZKZ,BMKOMBIKZ,BMANZTB,BMBAHNIG,BMPICKUP,BMABAUMKRS,BMABAUMLFD,BMSTKZL,BMBAABGZ,BMAPOS,BMRAFOLGE,BMAUSFFRB,B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,:BMPRODAUFBKZ:,:BMSPPART:,:BMPARTIE:,:BMPARTIEKZ:,:BMDATVW:,:BMDATDRU:,:BMDATABG:,:BMDATRP:,:BMDATRPM:,:BMDATANG:,:BMDATABWEB:,:BMERSATZKZ:,:BMKOMBIKZ:,:BMANZTB:,:BMBAHNIG:,:BMPICKUP:,:BMABAUMKRS:,:BMABAUMLFD:,:BMSTKZL:,:BMBAABGZ:,:BMAPOS:,:BMRAFOLGE:,:BMAUSFFRB:,:BMTAX:,:BMSCHIENE:,:BMMNRKRS:,:BMMLFDNR:,:BMMPOS:,:BMMAPOS:,:BMDL:,:BMBEARB:,:BMZULO:,:BMZULB:,:BMZULP:,:BMZUAUFBKZ:,:BMRART:,:BMRVAR:,:BMRFARBE:,:BMLIEFNR:,:BMBESTKZ:,:BMBNRLIEF:,:BMEGKZ:,:BMLIEFSCHNR:,:BMLIEFDAT:,:BMRECHNR:,:BMKLABR:,:BMEINPR:,:BMRECHDAT:,:BMBDEKZ:,:BMJJJJBDE:,:BMBNRBDE:,:BMDATBDE:,:BMBDEBKZ:,:BMJJJJMAT:,:BMBNRMAT:,:BMDATMAT:,:BMISOLLLG:,:BMIISTLG:,:BMIDIFFLG:,:BMIDATUM:,:BMISTATUS:,:BMIJJJJ:,:BMIBELEGNR:,:BMIBPOSVON:,:BMIBPOSBIS:,:BMRODA:,:BMWIND:,:BMVWMNRKRS:,:BMVWMLFDNR:,:BMVWMPOS:,:BMMUKZ:,:BMZTERL:,:BMVERSION:,:BMKGBRUTGW:,:BMFILLER:,:BMAENDZL:,:BMAENDBEN:,:BMAENDDAT:,:BMNEUBEN:,:BMNEUDAT:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public void DeleteBABST(string client, string krs, string lfd, string pos, int option = 1)
        {
            or1 = OracleDB.CreateCommand();

            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE BABST "
                + "  WHERE BMMANDANT=:BMMANDANT AND BMAUFKRS=:BMAUFKRS AND BMAUFLFD=:BMAUFLFD AND BMAUFPOS=:BMAUFPOS";
                    or1.Parameters.Add("BMMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("BMAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("BMAUFLFD", OracleType.NVarChar).Value = lfd;
                    or1.Parameters.Add("BMAUFPOS", OracleType.NVarChar).Value = pos;
                    break;
                case 2:
                    or1.CommandText = "DELETE BABST "
                + "  WHERE GAMANDANT=:BMMANDANT AND BMAUFKRS=:BMAUFKRS AND BMAUFLFD=:BMAUFLFD ";
                    or1.Parameters.Add("BMMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("BMAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("BMAUFLFD", OracleType.NVarChar).Value = lfd;

                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void UpdateBABST(DataRow dwData, int option = 1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    case "JLT":
                    default:
                        UBABST01(dwData);
                        break; 
                }
            }
            or1 = OracleDB.CreateCommand();
            switch (option)
            { 
                case 2: UBABST02(dwData);  break;
            }

            Connect2Proxy(or1);
        }
        public void UBABST01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BABST SET BMMANDANT=:BMMANDANT:,BMBAUMKRS=:BMBAUMKRS:,BMBAUMLFD=:BMBAUMLFD:,BMKART=:BMKART:,BMKVAR=:BMKVAR:,BMFARBE=:BMFARBE:,BMZENSUR=:BMZENSUR:,BMZUSTAND=:BMZUSTAND:,BMSCHLICHTGR=:BMSCHLICHTGR:,BMSCHLICHTNR=:BMSCHLICHTNR:,BMBAUMKZ=:BMBAUMKZ:,BMVERWEN=:BMVERWEN:,BMHERART=:BMHERART:,BMFDZ=:BMFDZ:,BMGABED=:BMGABED:,BMKETTTYP=:BMKETTTYP:,BMKANTE=:BMKANTE:,BMLO=:BMLO:,BMLB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BMFILLER:,BMAENDZL=:BMAENDZL:,BMAENDBEN=:BMAENDBEN:,BMAENDDAT=:BMAENDDAT:,BMNEUBEN=:BMNEUBEN:,BMNEUDAT=:BMNEUDAT:"
                 + " WHERE   BMMANDANT=:BMMANDANT: AND BMBAUMKRS=:BMBAUMKRS: AND BMBAUMLFD=:BMBAUMLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UBABST02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BABST SET  BMLO=:BMLO:, BMLB=:BMLB:, BMLP=:BMLP:,BMAENDBEN=:BMAENDBEN:,BMAENDDAT=:BMAENDDAT: "
               + " WHERE   BMMANDANT=:BMMANDANT: AND BMBAUMKRS=:BMBAUMKRS: AND BMBAUMLFD=:BMBAUMLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UBABST03(DataRow dwData)

        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BABST SET   BMLO=:BMLO:, BMLB=:BMLB:, BMLP=:BMLP:,BMSA=:BMSA:, BMAUFKRS=:BMAUFKRS:,BMAUFLFD=:BMAUFLFD:,BMAUFPOS=:BMAUFPOS:,BMAUFTYP=:BMAUFTYP:, BMDATANG=:BMDATANG:,BMMNRKRS=:BMMNRKRS:,BMMLFDNR=:BMMLFDNR:,BMMPOS=:BMMPOS:,BMAENDBEN=:BMAENDBEN:,BMAENDDAT=:BMAENDDAT: "
               + " WHERE   BMMANDANT=:BMMANDANT: AND BMBAUMKRS=:BMBAUMKRS: AND BMBAUMLFD=:BMBAUMLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UBABST04(DataRow dwData)

        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE BABST SET   BMLO=:BMLO:, BMLB=:BMLB:, BMLP=:BMLP:,BMDATANG=:BMDATANG:, BMDATABG=:BMDATABG:,BMRESTLG=:BMRESTLG:,BMRESTGEW=:BMRESTGEW:,BMURISTLG=:BMURISTLG:"
               + " WHERE   BMMANDANT=:BMMANDANT: AND BMBAUMKRS=:BMBAUMKRS: AND BMBAUMLFD=:BMBAUMLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
       
        public DataSet QueryBABST(DataRow dwData, int option = 1)
        { 
            switch (option)
            {
                case 0:
                    SResult = QBABST00(dwData);
                    break;
                case 1: 
                    SResult = QBABST01(dwData);
                    break;
                case 2:
                    SResult = QBABST02(dwData);
                    break;
                case 3:
                    SResult = QBABST03(dwData);
                    break;
                case 4:
                    SResult = QBABST04(dwData);
                    break;
                case 5:
                    SResult = QBABST05(dwData);
                    break;
                case 6:
                    SResult = QBABST06(dwData);
                    break;
                case 7:
                    SResult = QBABST07(dwData);
                    break; 
            } 
            return SResult;
        }
        public DataSet QBABST00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand(); 
            or1.CommandText = "SELECT * FROM BABST WHERE  ROWNUM<2 "; 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BABST"
                       + " WHERE  BMMANDANT=:BMMANDANT: AND BMBAUMKRS=:BMBAUMKRS: AND BMBAUMLFD=:BMBAUMLFD:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BABST"
                + " WHERE  BMMANDANT=:BMMANDANT: AND BMAUFKRS=:BMAUFKRS: AND BMAUFLFD=:BMAUFLFD: AND BMAUFPOS=:BMAUFPOS:"
                + " ORDER BY 1,2,3";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BABST"
                + " WHERE  BMMANDANT=:BMMANDANT: AND BMAUFKRS=:BMAUFKRS: AND BMAUFLFD=:BMAUFLFD: "; 
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BABST "
                + " WHERE   BMMANDANT=:BMMANDANT: AND BMKART=:BMKART: AND BMKVAR=:BMKVAR: AND BMFARBE=:BMFARBE: ";
             or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData); 
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT * FROM  BABST B JOIN BAZU Z ON BZMANDANT=BMMANDANT AND BZBAUMKRS=BMBAUMKRS AND BZBAUMLFD=BMBAUMLFD "
                + " WHERE   BZMANDANT=:BZMANDANT: AND BZAUFKRS=:BZAUFKRS: AND BZAUFLFD=:BZAUFLFD: AND BZAUFPOS=:BZAUFPOS:"
                + " ORDER BY 1,2,3";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST06(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT DISTINCT M.* FROM  BABST M JOIN ABPOS ON ABPMANDANT=BMMANDANT AND BMAUFKRS=ABPAUFKRS AND BMAUFLFD=ABPAUFLFD AND BMAUFPOS=ABPAUFPOS"
                + " WHERE  ABPMANDANT=:ABPMANDANT: AND ABPAUFKRS=:ABPAUFKRS: AND ABPAUFLFD=:ABPAUFLFD:"
                + " ORDER BY 1,2,3";
           
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QBABST07(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "select A.BMLO,A.BMLB,trim(A.BMLP) as bmlp,trim(A.BMKART) as bmkart,trim(A.BMFARBE) as bmfarbe,"
                          + " A.BMBAUMKRS,A.BMBAUMLFD, trim(A.BMKETTTYP) as BMKETTTYP,A.BMSOLLLG*0.1 AS BMSOLLLG,A.BMRESTLG*0.1 AS BMRESTLG from babst A"
                          + " where BMLO = '01' AND BMLB = 'ZZ' AND BMLEER<>'J' AND BMSOLLKZ<>'J'"
                          + " AND BMKART LIKE'" + dwData["BMKART"].ToString().Trim() + "%'"
                          + " AND BMLP LIKE '" + dwData["BMLP"].ToString().Trim() + "%' "
                          + " AND BMFARBE LIKE '" + dwData["BMFARBE"].ToString().Trim() + "%'"
                          + " ORDER BY BMKART,BMFARBE,BMBAUMLFD";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
    }
}
